//
//  UIBarButtonItem+CHExtension.m
//  ChancellorHouse
//
//  Created by VID on 16/10/31.
//  Copyright © 2016年 GPX_NSlog. All rights reserved.
//

#import "UIBarButtonItem+JyExtension.h"

@implementation UIBarButtonItem (JyExtension)

+ (instancetype)itemWithTitle:(NSString *)title image:(UIImage *) image hightedImage:(UIImage *)hightedImage target:(id) target action:(SEL) action{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setBackgroundImage:image forState:UIControlStateNormal];
    [button setBackgroundImage:hightedImage forState:UIControlStateHighlighted];
    button.imageView.contentMode = UIViewContentModeRight;
    [button setImageEdgeInsets:UIEdgeInsetsMake(0, -5, 0, 0)];
    [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; 
//    button.titleLabel.font = Font(15);
    
//    button.titleLabel.font=[UIFont fontWithName:@"TrebuchetMS-Bold" size:15];
    
    button.titleLabel.font=[UIFont systemFontOfSize:15];
 
    
    [button setTitle:title forState:UIControlStateNormal];
    [button sizeToFit];
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    
    return [[self alloc] initWithCustomView:button] ;
    
}
+ (instancetype)itemWithTitle:(NSString *)title target:(id) target action:(SEL) action {
    return [self itemWithTitle:title image:nil hightedImage:nil target:target action:action];
}
@end
